from enum import IntEnum, StrEnum


# 寄存器类型枚举
class RegisterType(IntEnum):
    COIL = 1
    DISCRETE_INPUT = 2
    HOLDING_REGISTER = 3
    INPUT_REGISTER = 4


class DecodeType(IntEnum):
    SignedInt = 1
    UnsignedInt = 2
    SignedLong = 3
    UnsignedLong = 4
    Float = 5


class InnerDecode(StrEnum):
    SignedShort = "SignedShort"
    UnsignedShort = "UnsignedShort"
    LongABCD = "LongABCD"
    LongCDAB = "LongCDAB"
    LongBADC = "LongBADC"
    LongDCBA = "LongDCBA"
    FloatABCD = "FloatABCD"
    FloatCDAB = "FloatCDAB"
    FloatBADC = "FloatBADC"
    FloatDCBA = "FloatDCBA"


class ByteOrder(StrEnum):
    # 标准字节序
    BigEndFloat = ">f"  # 大端float（高字节在前）
    LittleEndFloat = "<f"  # 小端float（低字节在前）
    WordSwappedFloat = ">f_"  # 字内反序float（2字节为单位交换）
    LittleEndWordSwappedFloat = "<f_"  # 小端字内反序float（先小端再2字节交换）

    BigEndSignedInt = ">i"  # 大端int
    LittleEndSignedInt = "<i"  # 小端int
    BigEndUnsignedInt = ">I"  # 大端无符号int
    LittleEndUnsignedInt = "<I"  # 小端无符号int
    BigEndSignedShort = ">h"  # 大端short
    LittleEndSignedShort = "<h"  # 小端short
    BigEndUnsignedShort = ">H"  # 大端无符号short
    LittleEndUnsignedShort = "<H"  # 小端无符号short

    # 大端字内反序版本
    BigEndWordSwappedSignedInt = ">i_"  # 大端字内反序int
    BigEndWordSwappedUnsignedInt = ">I_"  # 大端字内反序无符号int
    BigEndWordSwappedSignedShort = ">h_"  # 大端字内反序short
    BigEndWordSwappedUnsignedShort = ">H_"  # 大端字内反序无符号short

    # 小端字内反序版本
    LittleEndWordSwappedSignedInt = "<i_"
    LittleEndWordSwappedUnsignedInt = "<I_"
    LittleEndWordSwappedSignedShort = "<h_"
    LittleEndWordSwappedUnsignedShort = "<H_"
